﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DouYinFiddlerPlugin
{


    public partial class UserControl1 : UserControl
    {



        public static bool check = false;
     
        public UserControl1()
        {
            InitializeComponent();
       //     WireAllControls(this);
        }



        public bool getCheck()
        {
            return check; 
        }

        private void UserControl1_Load(object sender, EventArgs e)
        {

            //  CallJsFunction("aa","bb");

            
         checkBox1.Enabled = true;
         button1.Enabled = true;
         textBox1.Enabled = true;
         textBox2.Enabled = true;
         

        }


        public void CallJsFunction(string function,string par)
        {
            object[] objects = new object[1];
            objects[0] = par;

            Task.Run(() => {
                this.Invoke((Action)(() =>
                {
                   // webBrowser1.Document.InvokeScript(function, objects);
                }));
               
            });
        }


        public void addTextBox(string text)
        {

            this.Invoke(new Action(() =>
            {
                textBox2.Text += text + Environment.NewLine;

                textBox2.SelectionStart = textBox2.Text.Length;

                textBox2.ScrollToCaret();

                if (textBox2.Text.Length > 4096)
                {
                    textBox2.Clear();
                }

            }));
            
        }

        public void addLog(string text)
        {
            this.Invoke(new Action(() =>
            {
                textBox1.Text += "[" + DateTime.Now.ToLocalTime().ToString() + "]" + text + Environment.NewLine;
                textBox1.SelectionStart = textBox1.Text.Length;
                textBox1.ScrollToCaret();

                if (textBox1.Text.Length > 4096)
                {
                   
                    textBox1.Clear();
                }

            }));
        }

        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("https://it.o.ls");
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Diagnostics.Process.Start("https://live.douyin.com/");
        }

        private void checkBox1_CheckStateChanged(object sender, EventArgs e)
        {
            check = checkBox1.Checked;
        }

        private void button2_Click(object sender, EventArgs e)
        {

           
        }
    }
}
